import numpy as np
import cv2
import matplotlib.pylab as pylab


img = cv2.imread("picture.jpg")
cv2.imshow("demo", img)  # 图像窗口显示
# cv2.waitKey()  # 等待

print(img.shape)
print(type(img))

# 通道顺序: B, G, R
# 图像本质是一个三维矩阵 [长][宽][三通道]
b = img[:, :, 0]
cv2.imshow("demo_B", b)  # 只显示蓝色
cv2.imshow("demo_G", img[:, :, 1])  # 只显示绿色
cv2.imshow("demo_R", img[:, :, 2])  # 只显示红色
cv2.waitKey()


# 画画
# draw = img.copy()
#
# cv2.line(img, (10, 50), (523, 523), (255, 0, 0), 3, cv2.LINE_8)
# cv2.rectangle(draw, (0, 32), (512, 228), (0, 255, 0), 3, cv2.LINE_4)
# cv2.circle(draw, (447, 63), 63, (0, 0, 255), -1)
# cv2.putText(draw, 'OpenCV', (10, 500), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
#
# cv2.imshow("draw", draw)
# cv2.waitKey()

# gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
# cv2.imshow("demo_gray", gray)
# cv2.imshow("demo_bin", thresh)
# cv2.waitKey()

